package com.miaostars.maitesen.listeners;

import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import com.miaostars.maitesen.core.QueueManager;

public class PortalListener implements Listener {
    private final QueueManager queueManager;

    public PortalListener(QueueManager queueManager) {
        this.queueManager = queueManager;
    }

    @EventHandler
    public void onPortalEnter(PlayerMoveEvent e) {
        if (e.getTo() == null || !isPortal(e.getTo())) return;
        queueManager.addPlayer("target_server", e.getPlayer());
    }

    private boolean isPortal(Location loc) {
        return loc.getBlock().getType() == Material.NETHER_PORTAL; // 检测下界传送门
    }
}